package atguigu06.polymorphism.exer2;

/**
 * ClassName: Test
 * Package: atguigu06.polymorphism.exer2
 * Description:
 *
 * @Author BuTang
 * @Create 2023/3/8 11:07
 * @Version 1.0
 */
public class Test {

    public void adopt(Animal animal){
        if (animal instanceof Dog) {
            animal = (Dog)animal;
            animal.eat();
            animal.jump();
            System.out.println(animal);
        }else{
            animal = (Cat)animal;
            animal.eat();
            animal.jump();
            System.out.println(animal);
        }
    }
    public static void main(String[] args) {
        Test test = new Test();
        test.adopt(new Dog());
        test.adopt(new Cat());
    }

}
